// app.ts

import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import { ResultInterceptor } from './common/intercepotor/result.interceptor'
import { FailFilter } from './common/filter/fail.filter'

async function bootstrap() {
  const app = await NestFactory.create(AppModule)

  const options = new DocumentBuilder().setTitle('itemall 项目接口文档').setVersion('1.0').build()

  const document = SwaggerModule.createDocument(app, options)
  SwaggerModule.setup('api', app, document)

  // 全局绑定拦截器
  app.useGlobalInterceptors(new ResultInterceptor())
  app.useGlobalFilters(new FailFilter())

  await app.listen(3000)
}
bootstrap()
